

package UIPanels;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseAdapter;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

//VS4E -- DO NOT REMOVE THIS LINE!
//public class PurchaseHistoryPanel extends JPanel
/**
 * this panel display coupon purchase history table that related to the 
 * user
 * @author Daniel
 *
 */
public class PurchaseHistoryPanel extends GeneralPanel
{
	private static final long serialVersionUID = 1L;
	public JTable jTable0;
	private JScrollPane jScrollPane0;
	private String[] colNames = {};
	private Object[][]  data = {} ;
	private JLabel jLabel1;
	private JButton back;
	private JTextArea jTextArea0;
	private JScrollPane jScrollPane1;
	private JLabel jLabel0;
	
	/**
	 * Constructor for Purchase HistoryPanel with no parameters.
	 * this function is used only for development need. to show panel with no frame running. 
	 */
	public PurchaseHistoryPanel()
	{
		initComponents();
	}
	
	/**
	 * Constructor for Purchase HistoryPanel with  parameters.
	 * 
	 * @param columNames - header,names of columns
	 * @param tableData - data of coupons for displaying in table
	 */
	public PurchaseHistoryPanel(String[] columNames, Object[][] tableData)
	{
		initComponents(columNames,tableData);
	}

	/**
	 * this function initiate all components at the panel.sets initial values and locating them on the
	 * panel.inserting the data from database that relevant for the current user.
	 * @param columNames - header,names of columns
	 * @param tableData - data of coupons for displaying in table
	 */
	private void initComponents(String[] columNames, Object[][] tableData) {
		colNames = columNames;
		data = tableData;
		setLayout(new GroupLayout());
		add(getJLabel1(), new Constraints(new Leading(84, 416, 12, 12), new Leading(34, 12, 12)));
		add(getBackButton(), new Constraints(new Leading(84, 12, 12), new Leading(285, 10, 10)));
		add(getJScrollPane0(), new Constraints(new Leading(84, 416, 10, 10), new Leading(94, 173, 12, 12)));
		add(getJScrollPane1(), new Constraints(new Leading(86, 416, 10, 10), new Leading(370, 39, 10, 10)));
		add(getJLabel0(), new Constraints(new Leading(174, 244, 10, 10), new Leading(335, 25, 10, 10)));
		setSize(584, 451);
		
	}

	private JScrollPane getJScrollPane0() {
		if (jScrollPane0 == null) {
			jScrollPane0 = new JScrollPane();
			jScrollPane0.setForeground(new Color(0, 128, 255));
			jScrollPane0.setViewportView(getJTable0());
			jScrollPane0.addMouseListener(new MouseAdapter() {
	
			});
		}
		return jScrollPane0;
	}
	public JTable getJTable0() {
		if (jTable0 == null) {
			jTable0 = new JTable(data,colNames);
			jTable0.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
			jTable0.setColumnSelectionAllowed(false);
			jTable0.setRowSelectionAllowed(true);
			
			/*jTable0.setModel(new DefaultTableModel(data,colNames) {
				private static final long serialVersionUID = 1L;
				Class<?>[] types = new Class<?>[] { Object.class, Object.class, };
	
				public Class<?> getColumnClass(int columnIndex) {
					return types[columnIndex];
				}
			});*/
		}
		return jTable0;
	}
	
	/**
	 * this function initiate all components at the panel.sets initial values and locating them on the
	 * panel
	 * this function is used only for development need. to show panel with no frame running. 
	 */
	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJLabel1(), new Constraints(new Leading(84, 416, 12, 12), new Leading(34, 12, 12)));
		add(getBackButton(), new Constraints(new Leading(84, 12, 12), new Leading(285, 10, 10)));
		add(getJScrollPane0(), new Constraints(new Leading(84, 416, 10, 10), new Leading(94, 173, 12, 12)));
		add(getJScrollPane1(), new Constraints(new Leading(86, 416, 10, 10), new Leading(370, 39, 10, 10)));
		add(getJLabel0(), new Constraints(new Leading(174, 244, 10, 10), new Leading(335, 25, 10, 10)));
		setSize(584, 451);
	}
	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setFont(new Font("Dialog", Font.BOLD, 24));
			jLabel0.setForeground(new Color(0, 128, 255));
			jLabel0.setText("Commercial Section ");
		}
		return jLabel0;
	}
	private JScrollPane getJScrollPane1() {
		if (jScrollPane1 == null) {
			jScrollPane1 = new JScrollPane();
			jScrollPane1.setBackground(Color.lightGray);
			jScrollPane1.setViewportView(getJTextArea0());
		}
		return jScrollPane1;
	}
	public JTextArea getJTextArea0() {
		if (jTextArea0 == null) {
			jTextArea0 = new JTextArea();
			jTextArea0.setBackground(Color.lightGray);
			jTextArea0.setAutoscrolls(false);
			jTextArea0.setSelectedTextColor(new Color(128, 128, 255));
		}
		return jTextArea0;
	}
	public JButton getBackButton() {
		if (back == null) {
			back = new JButton();
			back.setText("Back to Main Screen");
		}
		return back;
	}
	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setFont(new Font("Dialog", Font.BOLD, 36));
			jLabel1.setForeground(new Color(0, 128, 255));
			jLabel1.setText("Your Purchase History");
		}
		return jLabel1;
	}
	/*public String[] getRowAt(int row) {
	     String[] result = new String[colNames.length];

	     for (int i = 0; i < colNames.length; i++) {
	         result[i] = (String) jTable0.getModel().getValueAt(row, i);
	     }

	     return result;
	}*/
	 
	
	
	

}


